package com.huadao.cart_ccs.data.bo;

import com.huadao.cart_ccs.R;
import com.huadao.cart_ccs.main.CartApplication;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;

import java.util.Date;

@Entity
public class ExperimentStage {
    @Id
    private Long id;
    private long projectId;
    private int day;
    private String stage;
    private Date startDate;
    private Date endDate;

    public ExperimentStage() {
        this.day = 0;
        this.stage = CartApplication.getInstance().getString(R.string.prepare);
    }

    public ExperimentStage(int day, String stage) {
        this.day = day;
        this.stage = stage;
    }

    @Generated(hash = 2128306840)
    public ExperimentStage(Long id, long projectId, int day, String stage, Date startDate,
                           Date endDate) {
        this.id = id;
        this.projectId = projectId;
        this.day = day;
        this.stage = stage;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public String getStage() {
        return stage;
    }

    public void setStage(String stage) {
        this.stage = stage;
    }

    @Override
    public String toString() {
        return super.toString();
    }

    public ExperimentStage getNextStage() {
        return forwardStage(1);
    }

    //前进多个实验阶段
    public ExperimentStage forwardStage(int number) {
        int day = this.day + number;
        String stage = null;
        if (this.stage.equals(CartApplication.getInstance().getString(R.string.finishCulture))) {
            stage=this.stage;
        } else {
            switch (day) {
                case 0:
                    stage = CartApplication.getInstance().getString(R.string.prepare);
                    break;
                case 1:
                    stage = CartApplication.getInstance().getString(R.string.TCellActive);
                    break;
                case 2:
                case 3:
                    stage = CartApplication.getInstance().getString(R.string.InfectedObservation);
                    break;
                case 4:
                case 5:
                case 6:
                    stage = CartApplication.getInstance().getString(R.string.preConcentration);
                    break;
                case 7:
                case 8:
                case 9:
                case 10:
                    stage = CartApplication.getInstance().getString(R.string.postConcentration);
                    break;
                case 11:
                case 12:
                case 13:
                    stage = CartApplication.getInstance().getString(R.string.postConcentration);
                    break;
                default:
                    stage = "";
                    break;
            }
        }
        ExperimentStage experimentStage = new ExperimentStage();
        experimentStage.setProjectId(projectId);
        experimentStage.setDay(day);
        experimentStage.setStage(stage);
        return experimentStage;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public long getProjectId() {
        return this.projectId;
    }

    public void setProjectId(long projectId) {
        this.projectId = projectId;
    }

    public Date getStartDate() {
        return this.startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return this.endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public ExperimentStage finishCulture() {
        ExperimentStage experimentStage = new ExperimentStage();
        experimentStage.setProjectId(projectId);
        experimentStage.setDay(day);
        experimentStage.setStage(CartApplication.getInstance().getString(R.string.finishCulture));
        return experimentStage;
    }
}
